﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<BugzX.Models.HomeViewModel>" %>

<asp:Content ContentPlaceHolderID="contentJQuery" runat="server">

    $.getJSON("/services/projects.ashx",
        {
            action: "getall"
        },
        function (data) {

            $(".loading").hide();
            $("#navHtml").show();

            var html = "";

            $.each(data, function(idx, v) {

                html += "<li class=\"ui-state-default ui-corner-all\" data-project=\"" + v.name + "\">";
                html += "<p>" + v.name + "</p>";
                html += "<img src=\"" + v.logoUrl + "\" alt=\"" + v.name + "\" />";
                html += "</li>";
            });

            $(".projects").html(html);
        }
    );

    $(".projects li").live("mouseenter", function () {
        $(this).addClass("ui-state-hover");
    });

    $(".projects li").live("mouseleave", function () {
        $(this).removeClass("ui-state-hover");
    });

    $(".projects li").live("click", function() {

        var project = $(this).data("project");

        window.location = "/project/view/" + project;
    });

</asp:Content>

<asp:Content ContentPlaceHolderID="contentHead" runat="server">
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="contentErrorMessage" runat="server">

    <% if (this.Model != null && this.Model.LoginResult == false)
       { %>
        <div class="ui-widget">
			<div class="ui-state-error ui-corner-all" style="padding: 0 .7em;"> 
				<p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span> 
				<strong>Alert:</strong> Please enter a valid username/password.</p>
			</div>
		</div>
    <% } %>

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="contentMain" runat="server">

    <nav>
        <div class="loading"></div>
        <ul class="projects ui-widget ui-helper-clearfix">
        </ul>
    </nav>

</asp:Content>
